import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class StackTrace2Log {
    private static final Logger logger = LoggerFactory.getLogger(StackTrace2Log.class);
    public static void main(String[] args) throws IOException {
        System.out.println("We are going to do something interesting....");
        try {
            throw new NullPointerException("I am an exception in the code.");
        } catch (Exception e) {
             logger.error("{}",e);
        }
        return;
    }
}
